﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinFormsApp_OperateExcel
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn=new SqlConnection(System.Configuration.ConfigrationManager.ConnectionStrings["COTHZ_TESTConnectionString"].ConnectionString);
SqlCommand comm=new SqlCommand("select * from [COTHZ_TEST].[dbo].[MATWIPDTL]",conn);
            DataSet ds=new DataSet();
            SqlDataAdapter da=new SqlDataAdapter(comm);
            da.Fill(ds);
            if (MyExcelUtls.DataTable2Sheet(Microsoft.SqlServer.Server.MapPath(@"temp\demo12233.xls"), ds.Tables[0], 100));
            
        }
    }
}
